package com.corpgovernment.organization.enumm;

import java.util.Arrays;
import java.util.Objects;

/**
 * 默认代订范围
 */
public enum DefaultBookRangeEnum {

	All("All", "全部员工"),
	None("None", "无"),
	;

	private final String code;
	private final String desc;

	DefaultBookRangeEnum(String code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	public String getCode() {
		return code;
	}

	public String getDesc() {
		return desc;
	}

	/**
	 * 根据code查询默认代订范围（默认无）
	 *
	 * @param code
	 * @return
	 */
	public static DefaultBookRangeEnum getByCode(String code) {
		return Arrays.stream(DefaultBookRangeEnum.values()).filter(e -> Objects.equals(code, e.getCode())).findFirst().orElse(DefaultBookRangeEnum.None);
	}
}
